﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlInputImage : JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlInputImage htmlInputImage;

        public JHtmlInputImage(System.Web.UI.HtmlControls.HtmlInputImage htmlInputImage):base(htmlInputImage)
        {
            // TODO: Complete member initialization
            this.htmlInputImage = htmlInputImage;
        }

        public override void Val()
        {
            Value = htmlInputImage.Value;
        }

        public override void Val(string value)
        {
            htmlInputImage.Value = value;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "align":
                    Value = htmlInputImage.Align;
                    return;
                case "alt":
                    Value = htmlInputImage.Alt;
                    return;
                case "border":
                    Value = htmlInputImage.Border;
                    return; 
                case "src":
                    Value = htmlInputImage.Src;
                    return;  
                default:
                    base.Attr(key);
                    return;
            }
        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "align":
                    htmlInputImage.Align = value;
                    return;
                case "alt":
                    htmlInputImage.Alt = value;
                    return;
                case "border":
                    htmlInputImage.Border = b;
                    return;
                case "src":
                    htmlInputImage.Src = value;
                    return;
                default:
                    base.Attr(key, value);
                    return;
            }
        }
    }
}
